 
 // 基于原来函数扩展方法
 
 type Callback = () =>void
 type ReturnFn = (...arg:any[])=>void
 declare global {
 interface Function  {
    before(fn:Callback):ReturnFn
 }

 }
 //  Function 函数原形上绑定一个before方法
 Function.prototype.before =function(fn){
    return(...args)=>{
        fn(); //先调用before方法
        console.log(this,'this')
        // 
        this(...args)// 调用原有core方法
    }
 }

 function core(...args){
    console.log('core...',args)
 }

 function sun (...args){
    console.log('sun...',args)
 }


 let fn = core.before(()=>{
    console.log('core.before...')
 })

 let fn1 = sun.before(()=>{
    console.log('sun.before...')
 })

 fn(1,2,3)
 fn1('张三','李四')

 export {}

